import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import UserLogin from '@/pages/user/UserLogin.vue'
import UserRegister from '@/pages/user/UserRegister.vue'
import UserManagement from '@/pages/admin/UserManagement.vue'
import UserInfoModify from '@/pages/user/UserInfoModify.vue'
import AddPicture from '@/pages/picture/AddPicture.vue'
import PictureManagement from '@/pages/picture/PictureManagement.vue'
import PictureDetail from '@/pages/picture/PictureDetail.vue'
import BatchAddPicture from '@/pages/picture/BatchAddPicture.vue'
import SpaceManagement from '@/pages/space/SpaceManagement.vue'
import AddSpace from '@/pages/space/AddSpace.vue'
import SpaceTemp from '@/pages/space/SpaceTemp.vue'
import SpaceDetail from '@/pages/space/SpaceDetail.vue'
import SearchPicture from '@/pages/picture/SearchPicture.vue'
import AnalyzePicturePage from '@/pages/analyze/AnalyzePicturePage.vue'
import { SPACE_TYPE_ENUM } from '@/constants/spaceUser.ts'
import SpaceUserManagement from '@/pages/space/SpaceUserManagement.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
    },
    {
      // 用户登录
      path: '/user/login',
      name: 'login',
      component: UserLogin,
    },
    {
      //用户注册
      path: '/user/register',
      name: 'register',
      component: UserRegister,
    },
    {
      //用户管理
      path: '/admin/management',
      name: 'management',
      component: UserManagement,
    },
    {
      path:'/user/userInfoModify',
      name:'userInfoModify',
      component: UserInfoModify,
    },
    //添加图片
    {
      path:'/picture/addPicture',
      name:'addPicture',
      component: AddPicture,
    },
    //管理员批量导入图片
    {
      path:'/picture/batchAddPicture',
      name:'batchAddPicture',
      component: BatchAddPicture,
    },
    //管理员图片管理
    {
      path:'/admin/picture/managePic',
      name:'managePic',
      component: PictureManagement,
    },
    //图片详情页,包含路由传参
    //由于 props: true，这个 id 会被自动作为 props 传递给 PictureDetail 组件
    {
      path: '/picture/detail/:id',  // 这里添加:id参数
      name: 'detail',
      component: PictureDetail,
      props: true
    },
    //管理员空间管理
    {
      path:'/admin/space/manageSpace',
      name:'manageSpace',
      component: SpaceManagement,
    },
    //创建/修改空间 增加空间类型标识
    {
      path:'/space/addSpace/:spaceType',
      name:'addSpace',
      component: AddSpace,
      props: true
    },
    //跳转到私有图库中间页
    {
      path:'/space/spaceTemp',
      name:'spaceTemp',
      component: SpaceTemp,
    },
    //空间详情页,包含路由传参
    {
      path: '/space/detail',  // 这里添加:id参数
      name: 'spaceDetail',
      component: SpaceDetail,
    },
    //以图搜图页面
    {
      path: '/picture/searchPicture/:pictureId',  // 这里添加:id参数
      name: 'searchPicture',
      component: SearchPicture,
      props: true
    },
    //图库分析页面
    {
      path: '/analyze/picture',
      name: 'analyzePicture',
      component: AnalyzePicturePage,
    },
    //成员管理页面
    {
      path: '/space/spaceUserManage',
      name: 'spaceUserManage',
      component: SpaceUserManagement,
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue'),
    },
  ],
})

export default router
